package com.newford.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectAccessQueryDriver {

	public static void main(String[] args) {
		String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Documents and Settings\\Administrator\\rzy.mdb";
		try {
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			Connection conn = DriverManager.getConnection(strurl,"rzy","rzy");// 创建连接对象
			Statement stmt1=conn.createStatement();//创建数据处理对象  
			String sql = "select * from t_news";
			ResultSet rs = stmt1.executeQuery(sql);
			while(rs.next()){
				System.out.println(rs.getString(1));
				System.out.println(rs.getString(2));
				System.out.println(rs.getString(3));
				
			}
			stmt1.close();
			conn.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}

}
